<template>
  <tm-app ref="app">
    <tm-navbar title="奥集能" hide-home />
    <headers title="首页" :show="isShow" @open="open" @close="close" />
    <tag
      :tagSize="'n'"
      :taglist="Tags"
      :tagActive="tagActive"
      @btnClick="changeData"
    />
    <view v-if="tagActive === 'workbench'" class="custom-home-card">
      <card-template
        v-for="(item, index) in proTalData"
        :key="index"
        :title="item.title"
        :margin="[20, 20]"
        :padding="[20, 14]"
        :extra="item.extra"
        :list="item.info"
      />
    </view>
    <view v-else class="custom-home-card"> 计划中，尽情期待 </view>
  </tm-app>
</template>

<script lang="ts" setup>
import { Tags } from './config/index'
import { onMounted, ref } from 'vue'
import { IPortal } from './common/portalType'
import cardTemplate from './components/cardTemplate.vue'
import tag from '../../components/tag/index.vue'
import headers from '../../components/header/header.vue'
import porTal from './common/portal'
import { TabItems } from '@/ts/base/model'
let proTalData = ref<IPortal[]>([])
let isShow = ref<boolean>(false)
const tagActive = ref<string>('workbench')
// import { onShow, onLoad, onInit } from '@dcloudio/uni-app'
// const { proxy } = getCurrentInstance()
/** 加载数据 */
const getData = async () => {
  await porTal.initPortal()
  proTalData.value = porTal.getPortal()
}

async function changeData(item: TabItems) {
  tagActive.value = item.code
}

/** 打开弹窗 */
const open = () => {
  isShow.value = true
}

/** 关闭弹窗 */
const close = () => {
  isShow.value = false
}

onMounted(() => {
  getData()
})
</script>
<style lang="scss">
.custom-home-card {
  height: calc(100vh - 370rpx);
  overflow-y: scroll;
}
</style>
